package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderCommission;
import com.ruoyi.zsyh.service.IZsyhServiceOrderCommissionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务订单分成Controller
 * 
 * @author yuexl
 * @date 2022-03-18
 */
@Controller
@RequestMapping("/zsyh/serviceOrderCommission")
public class ZsyhServiceOrderCommissionController extends BaseController
{
    private String prefix = "zsyh/serviceOrderCommission";

    @Autowired
    private IZsyhServiceOrderCommissionService zsyhServiceOrderCommissionService;

    @RequiresPermissions("zsyh:serviceOrderCommission:view")
    @GetMapping()
    public String serviceOrderCommission()
    {
        return prefix + "/serviceOrderCommission";
    }

    /**
     * 查询服务订单分成列表
     */
    @RequiresPermissions("zsyh:serviceOrderCommission:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderCommission zsyhServiceOrderCommission)
    {
        startPage();
        List<ZsyhServiceOrderCommission> list = zsyhServiceOrderCommissionService.selectZsyhServiceOrderCommissionList(zsyhServiceOrderCommission);
        return getDataTable(list);
    }

    /**
     * 导出服务订单分成列表
     */
    @RequiresPermissions("zsyh:serviceOrderCommission:export")
    @Log(title = "服务订单分成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderCommission zsyhServiceOrderCommission)
    {
        List<ZsyhServiceOrderCommission> list = zsyhServiceOrderCommissionService.selectZsyhServiceOrderCommissionList(zsyhServiceOrderCommission);
        ExcelUtil<ZsyhServiceOrderCommission> util = new ExcelUtil<ZsyhServiceOrderCommission>(ZsyhServiceOrderCommission.class);
        return util.exportExcel(list, "服务订单分成数据");
    }

    /**
     * 新增服务订单分成
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存服务订单分成
     */
    @RequiresPermissions("zsyh:serviceOrderCommission:add")
    @Log(title = "服务订单分成", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderCommission zsyhServiceOrderCommission)
    {
        return toAjax(zsyhServiceOrderCommissionService.insertZsyhServiceOrderCommission(zsyhServiceOrderCommission));
    }

    /**
     * 修改服务订单分成
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderCommission zsyhServiceOrderCommission = zsyhServiceOrderCommissionService.selectZsyhServiceOrderCommissionById(id);
        mmap.put("zsyhServiceOrderCommission", zsyhServiceOrderCommission);
        return prefix + "/edit";
    }

    /**
     * 修改保存服务订单分成
     */
    @RequiresPermissions("zsyh:serviceOrderCommission:edit")
    @Log(title = "服务订单分成", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderCommission zsyhServiceOrderCommission)
    {
        return toAjax(zsyhServiceOrderCommissionService.updateZsyhServiceOrderCommission(zsyhServiceOrderCommission));
    }

    /**
     * 删除服务订单分成
     */
    @RequiresPermissions("zsyh:serviceOrderCommission:remove")
    @Log(title = "服务订单分成", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderCommissionService.deleteZsyhServiceOrderCommissionByIds(ids));
    }
}
